package com.javainterface.controller;

import com.javainterface.service.BambookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/BambooCloud")
public class BambookController {

    @Autowired
    BambookService bambookService;

    //映射BIM系统属性
    @PostMapping("/SchemaService")
    @ResponseBody
    public String schema(@RequestBody String bodyparam) {
        String returnJson = bambookService.schemaService(bodyparam);
//        bambookService.clearMySqlBuffer();
        return returnJson;
    }

    //创建用户
    @PostMapping("/UserCreateService")
    @ResponseBody
    public String userCreate(@RequestBody String bodyparam) {
        String returnJson = bambookService.userCreateService(bodyparam);
//        bambookService.clearMySqlBuffer();
        return returnJson;
    }

    //修改用户
    @PostMapping("/UserUpdateService")
    @ResponseBody
    public String userUpdate(@RequestBody String bodyparam) {
        String returnJson = bambookService.userUpdateService(bodyparam);
//        bambookService.clearMySqlBuffer();
        return returnJson;
    }

    //删除用户(逻辑)
    @PostMapping("/UserDeleteService")
    @ResponseBody
    public String userDelete(@RequestBody String bodyparam) {
        String returnJson = bambookService.userDeleteService(bodyparam);
//        bambookService.clearMySqlBuffer();
        return returnJson;
    }

    //查询全部用户
    @PostMapping("/QueryAllUserIdsService")
    @ResponseBody
    public String QueryAllUserIds(@RequestBody String bodyparam) {
        String returnJson = bambookService.QueryAllUserIdsService(bodyparam);
//        bambookService.clearMySqlBuffer();
        return returnJson;
    }

    //根据ID查询用户
    @PostMapping("/QueryUserByIdService")
    @ResponseBody
    public String selectUserByUserId(@RequestBody String bodyparam) {
        String returnJson = bambookService.QueryUserByIdService(bodyparam);
//        bambookService.clearMySqlBuffer();
        return returnJson;
    }

    //创建组织
    @PostMapping("/OrgCreateService")
    @ResponseBody
    public String orgCreate(@RequestBody String bodyparam) {
        String returnJson = bambookService.orgCreateService(bodyparam);
//        bambookService.clearMySqlBuffer();
        return returnJson;
    }

    //更新组织
    @PostMapping("/OrgUpdateService")
    @ResponseBody
    public String orgUpdate(@RequestBody String bodyparam) {
        String returnJson = bambookService.orgUpdateService(bodyparam);
//        bambookService.clearMySqlBuffer();
        return returnJson;
    }

    //删除组织(逻辑)
    @PostMapping("/OrgDeleteService")
    @ResponseBody
    public String orgDelete(@RequestBody String bodyparam) {
        String returnJson = bambookService.orgDeleteService(bodyparam);
//        bambookService.clearMySqlBuffer();
        return returnJson;
    }

    @PostMapping("/OrgActiveService")
    @ResponseBody
    public String orgActive(@RequestBody String bodyparam) {
        String returnJson = bambookService.orgActiveService(bodyparam);
        return returnJson;
    }

    //查询全部组织
    @PostMapping("/QueryAllOrgIdsService")
    @ResponseBody
    public String orgList(@RequestBody String bodyparam) {
        String returnJson = bambookService.selectOrgList(bodyparam);
//        bambookService.clearMySqlBuffer();
        return returnJson;
    }

    //根据ID查询组织
    @PostMapping("/QueryOrgByIdService")
    @ResponseBody
    public String selectOrgByOrgList(@RequestBody String bodyparam) {
        String returnJson = bambookService.selectOrgByOrgId(bodyparam);
//        bambookService.clearMySqlBuffer();
        return returnJson;
    }

    @PostMapping("/ccc")
    @ResponseBody
    public String clearBuffer(){
        bambookService.clearMySqlBuffer();
        return "success...";
    }

}
